<!--
 * @Author: 闫一丹 1437921153@qq.com
 * @Date: 2022-12-23 00:30:11
 * @LastEditors: 闫一丹 1437921153@qq.com
 * @LastEditTime: 2023-01-01 11:59:36
 * @FilePath: \vue-xuexitong\src\views\PeopleHome.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup>
import { ref } from "vue";
import { showToast } from "vant";
import { storeToRefs } from 'pinia'
import { myNoteStore } from '@/stores/note.js'
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'

// 实例化仓库
const router = useRouter()
const noteStore = myNoteStore()
// 解构
const { shareNoteList } = noteStore
const { noteList } = storeToRefs(noteStore)

const concern = ref({
  id: 0,
  msg: "+ 关注",
});
function clickbtn() {
  if (concern.value.id == 0) {
    concern.value.id = 1;
    concern.value.msg = "已关注";
  } else {
    concern.value.id = 0;
    concern.value.msg = "+ 关注";
    showToast("取消关注");
  }
}
function toMyNote() {
  router.push('/mynote')
}
onMounted(async()=>{
  try {
    await shareNoteList(1)
  } catch (error) {
    return Promise.reject(error)
  }
})
// 返回上一级
const onClickLeft = () => history.back();
</script>

<template>
  <div class="peoplehome">
    <div class="card">
      <!-- 头部导航 -->
      <van-row justify="space-between">
        <van-col span="3" @click="onClickLeft"
          ><i class="iconfont icon-zuosanjiao"></i>
        </van-col>
        <van-col span="12"></van-col>
        <van-col span="3"><i class="iconfont icon-androidgengduo"></i></van-col>
      </van-row>
      <!-- 头像背景 -->
      <div class="people">
        <div class="img">
          <img src="/images/people.png" alt="" />
        </div>
        <div class="msg">
          <div>闫一丹</div>
          <van-tag color="#cccccc4c" round text-color="#fff">
            <img src="/images/success.png" alt="" />
            已认证</van-tag
          >
        </div>
        <div class="btn">
          <!-- <button class="concern" @click="clickbtn">已关注</button> -->
          <button class="no_concern" @click="clickbtn">
            {{ concern.msg }}
          </button>
        </div>
      </div>
      <div class="user_msg">
        <div><span>1</span>关注</div>
        <div><span>1</span>粉丝</div>
        <div><span>1</span>获赞</div>
      </div>
    </div>
    <div class="note">
      <h4>共享笔记</h4>
      <div class="cart">
        <div class="card_box" @click="toMyNote" v-for="(item,index) in noteList" :key="index">
          <h3 class="note_title">{{ item.note_title }}</h3>
          <div class="content">
            {{ item.note_text }}
          </div>
          <div class="note_foot">
            <span>14:30</span>
            <span>共享笔记</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
.peoplehome {
  //   width: 100%;
  //   height: 100%;
  position: fixed;
  width: 100%;
  height: 100%;
  background-color: #6d7278;
}
.van-row {
  text-align: center;
  padding-top: 10px;
  font-size: 18px;
}
.iconfont {
  font-size: 20px;
  color: #fff;
}
.card {
  background: url(/images/peoplebg.png) no-repeat center 0px;
  background-size: contain;
}
.concern {
  display: none;
  //   justify-content: center;
  //   align-items: center;
}
.people {
  display: flex;
  align-items: center;
  margin-top: 10px;
  img {
    width: 70px;
    margin: 20px 15px 20px 15px;
  }
  .msg {
    line-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    div {
      font-size: 18px;
      margin-bottom: 10px;
      color: #fff;
    }
    img {
      width: 20px;
      margin: 0 2px 0 0;
    }
  }
  .btn {
    margin-left: auto;
    padding: 10px;

    button {
      background-color: rgba(0, 0, 0, 0);
      border-radius: 15px;
      border: 2px solid #7b7c80;
      padding: 5px 10px;
      font-size: 14px;
      color: #fff;
    }
  }
}
.user_msg {
  display: flex;
  color: #fff;
  padding-bottom: 15px;
  div {
    margin: 8px;
    span {
      padding: 4px;
    }
  }
}
.note {
  position: fixed;
  height: 100%;
  width: 100%;
  background-color: #fff;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;

  h4 {
    margin: 12px;
    font-size: 15px;
    font-weight: 700;
  }
  .cart {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    .card_box {
      box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.16),
        0 6px 20px 0 rgba(0, 0, 0, 0.1);
      width: 40%;
      margin: 10px;
      padding: 5px;
      border-radius: 12px;

      .note_title {
        margin: 12px 0;
        font-weight: 700;
      }
      .content {
        overflow: hidden;
        padding-bottom: 40px;
        color: #cbcdd5;
      }
      .note_foot {
        display: flex;
        justify-content: space-between;
        span {
          font-size: 10px;
          color: #cbcdd5;
          padding: 3px;
        }
      }
    }
  }
}
</style>